using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using Gko.Utils;

namespace Gko.Video.Extensions
{
	[Serializable]
	public class DisplayMode : IEquatable<DisplayMode>
	{
		private readonly Resolution resolution;
		private readonly ColorDepth depth;

		public DisplayMode(Resolution resolution, ColorDepth depth)
		{
			this.resolution = resolution;
			this.depth = depth;
		}

		public Resolution Resolution
		{
			[DebuggerStepThrough]
			get
			{
				return this.resolution;
			}
		}

		public ColorDepth Depth
		{
			[DebuggerStepThrough]
			get
			{
				return this.depth;
			}
		}

		public int BufferSizeForData
		{
			get
			{
				return this.resolution.PixelsCount * (this.depth.BitsPerPixel / 8);
			}
		}

		public int BufferStride
		{
			get
			{
				return this.resolution.Width * (this.depth.BitsPerPixel / 8);
			}
		}

		public override string ToString()
		{
			return "Resolution: {0}, Depth: {1}".Format(this.resolution, this.depth);
		}

		public bool Equals(DisplayMode obj)
		{
			if (ReferenceEquals(null, obj)) {
				return false;
			}
			if (ReferenceEquals(this, obj)) {
				return true;
			}
			return Equals(obj.resolution, this.resolution) && Equals(obj.depth, this.depth);
		}

		public override bool Equals(object obj)
		{
			if (ReferenceEquals(null, obj)) {
				return false;
			}
			if (ReferenceEquals(this, obj)) {
				return true;
			}
			if (obj.GetType() != typeof(DisplayMode)) {
				return false;
			}
			return Equals((DisplayMode)obj);
		}

		public override int GetHashCode()
		{
			unchecked {
				return ((this.resolution != null ? this.resolution.GetHashCode() : 0) * 397) ^ (this.depth != null ? this.depth.GetHashCode() : 0);
			}
		}
	}
}